﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KontoraME
{
    public class GameObject
    {
        private int id;
        private int type;
        private Point point;
        private Size size;
        private Body body;
        private int value1;
        private int value2;
        
        #region Class GameObject Properties
        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        public int Type
        {
            get { return type; }
            set { type = value; }
        }

        public Point Point
        {
            get { return point; }
            set { point = value; }
        }

        public Size Size
        {
            get { return size; }
            set { size = value; }
        }

        public Body Body
        {
            get { return body; }
            set { body = value; }
        }

        public int Value1
        {
            get { return value1; }
            set { value1 = value; }
        }

        public int Value2
        {
            get { return value2; }
            set { value2 = value; }
        }

        #endregion

        #region Class GameObject Construtor
        public GameObject(int id, string type, Point point, int var1, int var2)
        {
            this.id = id;
            this.type = getTypeIDByName(type);
            this.point = point;
            Bitmap image = getImageByType();
            this.size = new Size(image.Width, image.Height);
            this.value1 = var1;
            this.value2 = var2;
        }

        public GameObject(int id, int type, Point point, int var1, int var2)
        {
            this.id = id;
            this.type = type;
            this.point = point;
            Bitmap image = getImageByType();
            this.size = new Size(image.Width, image.Height);
            this.value1 = var1;
            this.value2 = var2;
        }
        #endregion

        public int getTypeIDByName(string name)
        {
            switch (name)
            {
                case "running_man":
                    return GlobalConstants.RUNNING_MAN_ID;
                case "standing_man":
                    return GlobalConstants.STANDING_MAN_ID;
                case "blockhouse":
                    return GlobalConstants.BLOCKHOUSE_ID;
                case "machine_gun":
                    return GlobalConstants.MACHINE_GUN_ID;
                case "item_block":
                    return GlobalConstants.ITEM_BLOCK_ID;
                case "item_flying":
                    return GlobalConstants.ITEM_FLYING_ID;  
                case "bridge":
                    return GlobalConstants.BRIDGE_ID;
                case "boss1":
                    return GlobalConstants.BOSS1_ID;
                case "enemy_shelter":
                    return GlobalConstants.ENEMY_SHELTER_ID;
                case "stone_falling":
                    return GlobalConstants.STONE_FALLING_ID;
                case "stone_flying":
                    return GlobalConstants.STONE_FLYING_ID;
                case "fire":
                    return GlobalConstants.FIRE_ID;
                case "enemy_diver":
                    return GlobalConstants.ENEMY_DIVER_ID;
                case "boss3":
                    return GlobalConstants.BOSS3_ID;
                case "enemy_machine":
                    return GlobalConstants.ENEMY_MACHINE_ID;
                case "grenade":
                    return GlobalConstants.GRENADE_ID;
                case "tank":
                    return GlobalConstants.TANK_ID;
                case "boss5":
                    return GlobalConstants.BOSS5_DOOR_ID;
                default:
                    return 0;
            }
        }
        public Bitmap getImageByType()
        {
            Bitmap img = new Bitmap(GlobalConstants.STILE_SIZE, GlobalConstants.STILE_SIZE);
            switch (type) { 
                case GlobalConstants.RUNNING_MAN_ID:
                    img = new Bitmap(GlobalConstants.STILE_SIZE * 2, GlobalConstants.STILE_SIZE * 2);
                    img = global::KontoraME.Properties.Resources.running_man;
                    break;
                case GlobalConstants.STANDING_MAN_ID:
                    img = new Bitmap(GlobalConstants.STILE_SIZE * 2, GlobalConstants.STILE_SIZE * 2);
                    img = global::KontoraME.Properties.Resources.standing_man;
                    break;
                case GlobalConstants.BLOCKHOUSE_ID:
                    img = new Bitmap(GlobalConstants.STILE_SIZE * 2, GlobalConstants.STILE_SIZE * 2);
                    img = global::KontoraME.Properties.Resources.blockhouse;
                    break;
                case GlobalConstants.MACHINE_GUN_ID:
                    img = new Bitmap(GlobalConstants.STILE_SIZE * 2, GlobalConstants.STILE_SIZE * 2);
                    img = global::KontoraME.Properties.Resources.machine_gun;
                    break;
                case GlobalConstants.ITEM_BLOCK_ID:
                    img = new Bitmap(GlobalConstants.STILE_SIZE * 2, GlobalConstants.STILE_SIZE * 2);
                    img = global::KontoraME.Properties.Resources.item_bullet_block;
                    break;
                case GlobalConstants.ITEM_FLYING_ID:
                    img = new Bitmap(GlobalConstants.STILE_SIZE * 2, GlobalConstants.STILE_SIZE);
                    img = global::KontoraME.Properties.Resources.item_bullet_flying_map;
                    break;
                case GlobalConstants.BRIDGE_ID:
                    img = new Bitmap(256, 64);
                    img = global::KontoraME.Properties.Resources.bridge_map;
                    break;
                case GlobalConstants.BOSS1_ID:
                    img = new Bitmap(224, 384);
                    img = global::KontoraME.Properties.Resources.boss1_map;
                    break;
                case GlobalConstants.ENEMY_SHELTER_ID:
                    img = new Bitmap(64, 32);
                    img = global::KontoraME.Properties.Resources.enemy_shelter_map;
                    break;
                case GlobalConstants.STONE_FALLING_ID:
                    img = new Bitmap(64, 64);
                    img = global::KontoraME.Properties.Resources.stone_falling;
                    break;
                case GlobalConstants.STONE_FLYING_ID:
                    img = new Bitmap(64, 64);
                    img = global::KontoraME.Properties.Resources.stone_flying;
                    break;
                case GlobalConstants.FIRE_ID:
                    img = new Bitmap(32, 32);
                    img = global::KontoraME.Properties.Resources.fire_map;
                    break;
                case GlobalConstants.ENEMY_DIVER_ID:
                    img = new Bitmap(64, 32);
                    img = global::KontoraME.Properties.Resources.enemy_diver;
                    break;
                case GlobalConstants.BOSS3_ID:
                    img = new Bitmap(640, 448);
                    img = global::KontoraME.Properties.Resources.boss3_map;
                    break;
                case GlobalConstants.ENEMY_MACHINE_ID:
                    img = new Bitmap(64, 64);
                    img = global::KontoraME.Properties.Resources.enemy_machine;
                    break;
                case GlobalConstants.GRENADE_ID:
                    img = new Bitmap(64, 64);
                    img = global::KontoraME.Properties.Resources.grenade_map;
                    break;
                case GlobalConstants.TANK_ID:
                    img = new Bitmap(64, 64);
                    img = global::KontoraME.Properties.Resources.tank_map;
                    break;
                case GlobalConstants.BOSS5_DOOR_ID:
                    img = new Bitmap(64, 64);
                    img = global::KontoraME.Properties.Resources.boss5_map;
                    break;
            }
            return img;
        }
        public string getTypeNameById()
        {
            switch (type) 
            {
                case GlobalConstants.RUNNING_MAN_ID:
                    return "running_man";
                case GlobalConstants.STANDING_MAN_ID:
                    return "standing_man";
                case GlobalConstants.BLOCKHOUSE_ID:
                    return "blockhouse";
                case GlobalConstants.MACHINE_GUN_ID:
                    return "machine_gun";
                case GlobalConstants.ITEM_BLOCK_ID:
                    return "item_block";
                case GlobalConstants.ITEM_FLYING_ID:
                    return "item_flying";
                case GlobalConstants.BRIDGE_ID:
                    return "bridge";
                case GlobalConstants.BOSS1_ID:
                    return "boss1";
                case GlobalConstants.ENEMY_SHELTER_ID:
                    return "enemy_shelter";
                case GlobalConstants.STONE_FALLING_ID:
                    return "stone_falling";
                case GlobalConstants.STONE_FLYING_ID:
                    return "stone_flying";
                case GlobalConstants.FIRE_ID:
                    return "fire";
                case GlobalConstants.ENEMY_DIVER_ID:
                    return "enemy_diver";
                case GlobalConstants.BOSS3_ID:
                    return "boss3";
                case GlobalConstants.ENEMY_MACHINE_ID:
                    return "enemy_machine";
                case GlobalConstants.GRENADE_ID:
                    return "grenade";
                case GlobalConstants.TANK_ID:
                    return "tank";
                case GlobalConstants.BOSS5_DOOR_ID:
                    return "boss5";
                default:
                    return "";
            }
        }
    }
}
